import functionnodes.FunctionNode;
import data.Value;

/**
 * @author loaner
 */
class functionnodes.FunctionNodeIf extends FunctionNode {
	
	function FunctionNodeIf() {
		super();
		funcname = "if";
		type = SPECIALFUNCTION;
	}
	
	public function reduceXMLtoValue( scope : Object, args : Array) : Value 
	{
		trace( "Let's get the value of the first arg, which is " + args[0] );
		var returnvalue:Value;
		var firstvalue:Value = Evaluator.convertXMLtoValue( args[0], scope ) ;
		if( firstvalue.raw() )
		{
			returnvalue = Evaluator.convertXMLtoValue( args[1], scope ) ;
		}
		else
		{
			returnvalue = Evaluator.convertXMLtoValue( args[2], scope ) ;
		}
		return returnvalue;
	}

}